package cc.sunni.api.controller.article;

import cc.sunni.common.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@Api(value = "门户端文章业务的controller", tags = {"门户端文章业务的controller"})
@RequestMapping("portal/article")
public interface ArticlePortalControllerApi {

    @GetMapping("list")
    @ApiOperation(value = "首页查询文章列表", notes = "首页查询文章列表", httpMethod = "GET")
    R list(@RequestParam String keyword, @RequestParam Integer category,
           @ApiParam(name = "page", value = "查询下一页的第几页")
           @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
           @ApiParam(name = "pageSize", value = "分页的每一页显示的条数")
           @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize);

    @GetMapping("hotList")
    @ApiOperation(value = "首页查询热闻列表", notes = "首页查询热闻列表", httpMethod = "GET")
    R hotList();


    @GetMapping("queryArticleListOfWriter")
    @ApiOperation(value = "查询作家发布的所有文章列表", notes = "查询作家发布的所有文章列表", httpMethod = "GET")
    R queryArticleListOfWriter(@RequestParam String writerId,
                               @ApiParam(name = "page", value = "查询下一页的第几页")
                               @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                               @ApiParam(name = "pageSize", value = "分页的每一页显示的条数")
                               @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize);

    @GetMapping("queryGoodArticleListOfWriter")
    @ApiOperation(value = "作家页面查询近期佳文", notes = "作家页面查询近期佳文", httpMethod = "GET")
    R queryGoodArticleListOfWriter(@RequestParam String writerId);

    @GetMapping("detail")
    @ApiOperation(value = "文章详情查询", notes = "文章详情查询", httpMethod = "GET")
    R detail(@RequestParam String articleId);

    @PostMapping("readArticle")
    @ApiOperation(value = "阅读文章，文章阅读量累加", notes = "阅读文章，文章阅读量累加", httpMethod = "POST")
    R readArticle(@RequestParam String articleId, HttpServletRequest request);

    @GetMapping("readCounts")
    @ApiOperation(value = "获得文章阅读数", notes = "获得文章阅读数", httpMethod = "GET")
    Integer readCounts(@RequestParam String articleId);
}
